package com.tomorrow.runner.entertainment;

import com.amap.api.maps2d.model.LatLng;
import com.tomorrow.runner.activity.basic.BasicActivity;

/**
 *
 * Created by tomorrow on 16-4-30.
 */
public class Player {
    public static final int STATUS_ACTIVE = 1;
    public static final int STATUS_WAIT = 2;
    public static final int STATUS_DEATH = 0;
    public static final int STATUS_DONE = 3;
    public static final int IMMORTAL = -1;
    public static final int DEFAULT_HEALTH = 10;
    protected int id;
    protected int status;
    protected LatLng position;
    protected BasicActivity context;
    protected int health;
    protected long birthTime;
    protected long lifeTime;
    protected OnPlayerStatusChangedListener listener;
    public Player(int id, LatLng position,long lifeTime, BasicActivity context){
        this.id = id;
        this.position = position;
        this.context = context;
        this.birthTime = System.currentTimeMillis();
        this.lifeTime = lifeTime;
        this.health = DEFAULT_HEALTH;
    }
    public void setHealth(int health) {
        this.health = health;
    }
    public void changeStatus(int status){
        if (listener != null){
            listener.onStatusChanged(this.status,status);
        }
        this.status = status;
    }

    public int getHealth() {
        return health;
    }

    public void setListener(OnPlayerStatusChangedListener listener) {
        this.listener = listener;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public LatLng getPosition() {
        return position;
    }

    public void setPosition(LatLng position) {
        this.position = position;
    }

    public BasicActivity getContext() {
        return context;
    }

    public void setContext(BasicActivity context) {
        this.context = context;
    }

    public long getBirthTime() {
        return birthTime;
    }

    public long getLifeTime() {
        return lifeTime;
    }

    public void setLifeTime(long lifeTime) {
        this.lifeTime = lifeTime;
    }
}
